Array.prototype.filter2 = function (Fun, thisArg) {
    if (typeof Fun !== 'function') {
        throw new TypeError(`${Fun} is not function`)
    }

    let len = this.length
    let result = []
    for (let i = 0; i < len; i++) {
        if (Object.prototype.hasOwnProperty.call(this, i)) {
            if (Fun.call(thisArg, this[i], i, this)) {
                result.push(this[i])
            }
        }
    }

    return result

}

let arr = [7, 9, 4, 2]
let re = arr.filter2((item) => item > 6)
console.log(re);